package ex2.trans;

import ex2.Employee;
import ex2.PayrollDatabase;
import ex2.Transaction;
import ex2.exception.NoSuchEmployeeException;

public class DeleteEmployeeTRansaction implements Transaction {

    private int empId;

    public DeleteEmployeeTRansaction(int empId) {
        this.empId = empId;

    }

    @Override
    public void execute() {
        // 检查雇员是否存在
        Employee e = PayrollDatabase.getEmployee(empId);
        if (e != null) {
            PayrollDatabase.deleteEmployee(empId);
        } else {
            throw new NoSuchEmployeeException();
        }

    }

}
